/*
 * @Author: Wangjun
 * @Date: 2023-08-14 10:40:47
 * @LastEditTime: 2023-09-06 09:19:13
 * @LastEditors: Wangjun
 * @Description: 无实际意义，需要用正常算子替换
 * @FilePath: \nodex\nodeio\op_do.go
 * hnxr
 */
package nodeio

import (
	"gitee.com/hnxr_1/nodex"
)

func init() {
	nodex.Reister(new(DO))
}

type DO struct {
	nodex.Node
	Y nodex.Boolean `remark:"输入值"`
}

func (m *DO) GetModelID() int {
	return nodex.ModOut
}

func (m *DO) Init(mem *nodex.Memory) (err error) {
	outs := make([]*nodex.Out, 1)
	outs[0] = &nodex.Out{Name: "Y", Value: m.Y.BoolValue}
	m.SetOuts(outs)
	return
}
func (m *DO) GetName() string {
	return "DO"
}

/**
 * @description: 节点信息
 * @return {*}
 */
func (m *DO) RegData() []byte {
	return nodex.MakeRegData(m, "开关量输出", m.GetName(), "")
}

func (m *DO) Calc() (err error) {
	m.Bad = false
	return
}

func (m *DO) GetResult() (v float64, isBad bool) {
	if m.Y.Value {
		v = 1
	} else {
		v = 0
	}
	isBad = *m.Y.Bad
	return
}
